package mylibrary.xml.sax;

import java.io.File;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

//import org.apache.xerces.parsers.SAXParser;
import org.xml.sax.Attributes;
import org.xml.sax.helpers.DefaultHandler;



public class Test extends DefaultHandler {

	public static void main(String[] args) throws Exception {
		
		String a = "11111111";
		String b = "2222222";
		String s = a + b;
		//SAXParser parser =  new SAXParser();
		//parser.setContentHandler(new Test());
		//parser.parse("bin\\app-context.xml");
		
		SAXParserFactory factory = SAXParserFactory.newInstance();
		factory.setValidating(true);
		factory.setNamespaceAware(true);
		
		SAXParser parser = factory.newSAXParser();
		parser.parse(new File("bin\\app-context.xml"), new Test());
		
	}
	
	public void startElement(String uri,String localName,String qName,Attributes attr) {
		
		System.out.println("---------------------");
		System.out.println(uri);
		System.out.println(localName);
		System.out.println(qName);
		System.out.println(attr);
		System.out.println("---------------------");
		
		if(attr.getLength() > 0) {
			
			for(int i=0; i<attr.getLength(); i++) {
				
				System.out.println(attr.getQName(i) + " = " + attr.getValue(i));
			}
		}
	}
}
